/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.ref;

import java.lang.reflect.Method;

/**
 * <p>Project: app2022 - AppleTest
 * <p>Powered by webrx On 2022-02-09 11:52:46
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class AppleTest {
    public static void main(String[] args) throws Exception {

        var a = Class.forName("cn.ref.Apple");
        Method m = a.getMethod("setPrice", int.class);
        //System.out.println(m.getName());
        //相当于实例化

        //相当于 Apple a = new Apple(66);
        var a2 = a.getConstructor(int.class).newInstance(66);
        //相当于a2.setPrice(16);
        //m.invoke(a2, 16);

        var mget = a.getMethod("getPrice");
        Object p = mget.invoke(a2);
        System.out.println(p);
    }
}
